<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>

<%
//定义默认的action名称
String queryAction = "query.action";
String colspan = (String)request.getParameter("cols");
String temp;
//获取传入查询action，参数名：q[uery]
temp = (String)request.getParameter("q");
if (temp != null && !"".equals(temp))
	queryAction = temp.replace(".action","") + ".action";
%>


<script language="javascript">
function $(name){return document.getElementsByName(name);}
function getChecked(){
	var items = new Array();
	var obj =$("id");
	for(var i = 0; i < obj.length; i++){
		if(obj[i].checked){
			var item = {};
			item.id = obj[i].value;
			//获取所在行的其他数据
			var tr = obj[i].parentNode.parentNode;
			item.cols = new Array();
			for(var j = 0; j < tr.cells.length; j++){
				item.cols[j] = tr.cells[j].innerText;
			}
			items[items.length] = item;
		}
	}
	return items;
}
<!--

//分页
function queryByPage(mark){
	var currPageStr = document.getElementsByName("currPageStr")[0].value;
	var totalCounts = document.getElementsByName("totalCounts")[0].value;
	var pageCounts = document.getElementsByName("pageCounts")[0].value;
	var lastPage;
		
	if(mark=='first'){
		document.getElementsByName("currPageStr")[0].value=1;
	}
	if(mark=='next'){
		if(Number(totalCounts)%Number(pageCounts)==0){
		 		lastPage = Number(totalCounts)/Number(pageCounts)
		}else{
			lastPage = Math.floor( Number(totalCounts)/Number(pageCounts))+Number(1);
		}
		if(Number(lastPage) < Number(currPageStr)+Number(1)){
			document.getElementsByName("currPageStr")[0].value = lastPage;
		}
		else{
			document.getElementsByName("currPageStr")[0].value=Number(currPageStr)+Number(1);
		}
	}
	if(mark=='pre'){
		if(currPageStr==1){
			document.getElementsByName("currPageStr")[0].value=1;
		}else{
			document.getElementsByName("currPageStr")[0].value=Number(currPageStr)-Number(1);
		}
	}
	if(mark=='last'){
		if(Number(totalCounts)%Number(pageCounts)==0){
			document.getElementsByName("currPageStr")[0].value = Number(totalCounts)/Number(pageCounts)
		}else{
			document.getElementsByName("currPageStr")[0].value =Math.floor( Number(totalCounts)/Number(pageCounts))+Number(1);
		}
	}
	document.forms[0].action="<%=queryAction %>";
	document.forms[0].submit();
}

//-->
</script>
<tr bgcolor="#FAFAF1">
	<td height="30" colspan=<%=Integer.parseInt(colspan) %>>
		<div style=" float:left; margin-left: 10px;">
			<a href="javascript:doSelect();" class="coolbg">确定</a>
			<a href="javascript:parent.ClosePop();" class="coolbg">取消</a>
		</div>
		<!-- 必要的隐藏域 -->
		<s:hidden name="currPageStr"/>
		<s:hidden name="totalCounts"/>
		<s:hidden name="pageCounts"/>
		<!-- 分页 -->
		<div style="margin-right: 5px; text-align: right;">
			<s:a href="#" onclick="queryByPage('first');">[首页]</s:a>
			<s:a href="#" onclick="queryByPage('pre');">[上一页]</s:a>
			<s:a href="#" onclick="queryByPage('next');">[下一页]</s:a>
			<s:a href="#" onclick="queryByPage('last');">[末页]</s:a>
		</div>
	</td>
</tr>